package CreateNewItem.WIN;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   AddNewPartLI.java

import java.sql.*;

// Referenced classes of package win:
//            DnkFunctions

public class AddNewPartLI
{

    public AddNewPartLI()
    {
        try
        {
            DnkFunctions dnk = new DnkFunctions();
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            Statement st1 = con.createStatement();
            Statement st2 = con.createStatement();
            Statement st3 = con.createStatement();
            Statement st4 = con.createStatement();
            Statement st5 = con.createStatement();
            Statement st6 = con.createStatement();
//            try
//            {
//                st4.execute("delete * from tblnu;");
//                st.execute((new StringBuilder()).append("select * from ").append(args[0]).toString());
//                ResultSet rs = st.getResultSet();
//                if(rs != null)
//                {
//                    String DESCRIPT;
//                    String MODEL;
//                    String NEW_DES;
//                    for(; rs.next(); st1.execute((new StringBuilder()).append("INSERT INTO TBLNU (ITEM_NO,PART_NO,BRAND,MODEL,CATALOG,DESCRIPT,R_COST,COST,RETAIL,QOH,CONTROL,LI_WARE,POSITION,NEW_DES,NEW_MOD,YR_L,YR_H,REMARK) VALUES('").append(rs.getString("ITEM_NO")).append("','").append(rs.getString("PART_NO")).append("','").append(rs.getString("BRAND")).append("','").append(MODEL).append("',").append(dnk.getCategoryID(rs.getString("CATALOG"))).append(",'").append(DESCRIPT).append("',").append(rs.getDouble("R_COST")).append(",").append(rs.getDouble("COST")).append(",").append(rs.getDouble("RETAIL")).append(",").append(rs.getDouble("QOH")).append(",'").append(rs.getString("CONTROL")).append("',").append(rs.getDouble("LI_WARE")).append(",'").append(rs.getString("POSITION")).append("','").append(NEW_DES).append("','").append(rs.getString("NEW_MOD")).append("',").append(rs.getDouble("YR_L")).append(",").append(rs.getDouble("YR_H")).append(",'").append(rs.getString("REMARK")).append("');").toString()))
//                    {
//                        DESCRIPT = rs.getString("DESCRIPT");
//                        DESCRIPT = DESCRIPT.replaceAll("'", " ");
//                        MODEL = rs.getString("MODEL");
//                        MODEL = MODEL.replaceAll("'", " ");
//                        NEW_DES = rs.getString("NEW_DES");
//                        NEW_DES = NEW_DES.replaceAll("'", " ");
//                    }
//
//                }
//            }
//            catch(SQLException er)
//            {
//                er.printStackTrace();
//            }
            try
            {
                st3.execute("select * from tblnu;");
                ResultSet rs1 = st3.getResultSet();
                if(rs1 != null)
                    while(rs1.next()) 
                    {
//                        String CONTROL = rs1.getString("CONTROL").replaceAll("null", " ");
                        String CONTROL = " ";
                        String mmo = CONTROL + rs1.getString("REMARK");
                        String mmo1 = mmo.trim();
                        try
                        {
                            st2.execute((new StringBuilder()).append("INSERT INTO tblinventory ( categoryid, [part#], description, unittype, unit, unitcost, sellingprice, instock, onorder, onhold, onrma, parvalue, location, serialized, [vendor#], discontinued, weight, taxable, vendor1id, vendor2id, vendor3id, lpp, lpf, ldp, lqp, [upc#], revenueglid, inventoryglid, currentcost, warehouseid, [product#], internet, internetprice, cogid, addinfulfillmentallowed, make, mdl, modeltype, beginyr, endyr, prefix, nagscode, dnkcode, cif, retailprice, sellingprice2, [memo], westwp, fob_t, ecp, ppgprice, slprice, mprice, shapeid, country, [bin#], prpkey, ppgloc, instock1, POSITION, NEW_DES ) SELECT top 1 b.CATALOG, b.item_no, b.descript, NULL, NULL, b.r_cost, b.retail, b.qoh, 0, 0, 0, 0, b.location, no, NULL, no, 0, yes, 0, 0, 0, 0, 0, 0, 0, NULL, 1, 1, 0, 2, b.part_no, yes, b.retail, 1, yes, b.brand, B.MODEL, B.NEW_MOD, b.yr_l, b.yr_h, NULL, NULL, b.item_no, b.cost, b.retail, b.retail, '").append(mmo1).append("', 0, 0, ").append("0, 0, 0, 0, 18, NULL, NULL, 0, NULL, ").append("B.LI_WARE, POSITION, NEW_DES ").append("FROM TBLNU AS b where b.item_no ='").append(rs1.getString("ITEM_NO")).append("';").toString());
                        }
                        catch(SQLException er) { }
                    }
                System.out.println("tblinventory");
            }
            catch(SQLException er)
            {
                er.printStackTrace();
            }
            try
            {
                st5.execute("INSERT INTO tblmodel ( [part#], make, mdl, modeltype, Description, Beginyr, Endyr, WarehouseID, position, new_des ) SELECT item_no, brand, model, new_mod, descript, yr_l, yr_h, 2, position, new_des FROM tblnu;");

            }

            catch(SQLException er) { }
            System.out.println("tblmodel");
            try
            {
                st6.execute("INSERT INTO TBLINVENTORYCOSTING ( INVID, QTY, DATERECEIVED, USED, COST, VENDORID ) SELECT DISTINCT A.INVID, A.INSTOCK, NOW(), 0, 0, NULL FROM TBLINVENTORY AS A INNER JOIN tblnu AS B ON A.[PART#]=B.[ITEM_NO];");
            }
            catch(SQLException er) { }
            System.out.println("tblinventorycosting");
            st.close();
            st1.close();
            st2.close();
            st3.close();
            st4.close();
            st5.close();
            st6.close();
            con.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        System.out.println("Add item Compelte");
    }

}
